# Author:Yiye
# -*- codeing = utf-8 -*-
# @Time :2021/11/11 13:57
# @Author:李卓
# @Site : 
# @File : post请求.py
# @Software : PyCharm
import urllib.request
import urllib.parse

url = 'https://fanyi.baidu.com/sug'
headers = {
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.71 Safari/537.36'
}
data = {
    'kw': 'spider'
}
data = urllib.parse.urlencode(data).encode('utf8')
request = urllib.request.Request(url=url, data=data, headers=headers)
response = urllib.request.urlopen(request)
content =  response.read()
print(type(content))
import json
obj = json.loads(content)
print(obj)
